package com.lwj.dubbo;

import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.demo.DemoService;
import org.apache.dubbo.rpc.RpcContext;

import java.util.concurrent.CompletableFuture;

@Service
public class DemoImpl implements DemoService {
    @Override
    public String sayHello(String name) {

        return "Hello " + name + ", response from provider: " +
                RpcContext.getContext().getLocalAddress()+" serverRegion:"+System.getenv("serverRegion");
    }

    @Override
    public CompletableFuture<String> sayHelloAsync(String name) {
        CompletableFuture<String> cf = CompletableFuture.supplyAsync(() -> {
            return "async result";
        });
        return cf;
    }
}
